package com.cango.qutz.web.auth.resource.service.impl;


import java.util.List;

import com.cango.qutz.web.auth.resource.dao.IResourceDao;
import com.cango.qutz.web.auth.resource.service.IResourceService;
import com.cango.framework.base.pagination.PageInfo;
import com.cango.qutz.web.entity.ResourceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cango.qutz.web.entity.ResourceEntity;
import com.cango.framework.base.pagination.PaginationResult;

@Service("resourceService")
public class ResourceServiceImpl implements IResourceService {
	/**  系统资源sql的命名空间*/
	private static final String SQL_NAMESPACE = "resource.";
	
	/**  新增系统资源的sql id*/
	private static final String SQL_INSERT = "insertResource";
	
	/**  更新系统资源的sql id*/
	private static final String SQL_UPDATE = "updateResource";
	
	/**  删除系统资源的sql id*/
	private static final String SQL_DELETE = "deleteResource";
	
	/**  根据主键查询系统资源的sql id*/
	private static final String SQL_QUERY_BY_ID = "queryResourceById";
	
	/**  查询系统资源的sql id*/
	private static final String SQL_QUERY_FOR_LIST = "queryResources";
	
	/**  分页查询系统资源的sql id*/
	private static final String SQL_QUERY_BY_PAGE = "queryResourcesByPage";
	
    @Autowired
    private IResourceDao resourceDao;
    
    @Override
    public int insert(ResourceEntity resource) {
        int id=resourceDao.insert(SQL_NAMESPACE + SQL_INSERT, resource);
        return id;
    }

    @Override
    public int update(ResourceEntity resource) {
        return resourceDao.update(SQL_NAMESPACE + SQL_UPDATE, resource);
    }

    @Override
    public int delete(ResourceEntity resource) {
        return resourceDao.delete(SQL_NAMESPACE + SQL_DELETE, resource);
    }

    @Override
    public ResourceEntity queryObjectById(String resourceCode) {
        return resourceDao.queryObjectById(SQL_NAMESPACE + SQL_QUERY_BY_ID, resourceCode);
    }

    @Override
    public List<ResourceEntity> queryList(Object param) {
        return resourceDao.queryList(SQL_NAMESPACE + SQL_QUERY_FOR_LIST, param);
    }

    @Override
    public PaginationResult<ResourceEntity> queryListByPage(ResourceEntity param, PageInfo pageinfo) {
       return resourceDao.queryListByPage(SQL_NAMESPACE + SQL_QUERY_BY_PAGE, param, pageinfo);
    }
    
}
